/*
 * EstadoResultados.java
 *
 * Created on 6 de septiembre de 2008, 03:27 PM
 */

package administrador;

import java.math.RoundingMode;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Date;
import java.util.Vector;


/**
 *
 * @author  daniel1
 */
public class EstadoResultados extends javax.swing.JPanel {
Conexion conexion;
Usuario user;
AdministradorView aview;
Vector vMayor;

//Nath Redondeo
NumberFormat nf = NumberFormat.getNumberInstance();

    /** Creates new form EstadoResultados */
    public EstadoResultados(Conexion cEnt,Usuario user,AdministradorView aview,Vector vectMayor) {
        DecimalFormat dec=(DecimalFormat)nf;
        dec.applyPattern("###.##");
         //Configuro Redondeo
        nf.setMaximumFractionDigits(2);
        nf.setRoundingMode(RoundingMode.HALF_UP);
        
        vMayor=vectMayor;
        this.aview=aview;
        conexion=cEnt;
        this.user=user;
        initComponents();
        cargoDatos();
        configuroAnchoCol();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabla = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        lbl_nombre = new javax.swing.JLabel();
        lbl_ruc = new javax.swing.JLabel();
        lbl_titulo = new javax.swing.JLabel();
        lbl_fecha = new javax.swing.JLabel();

        setName("Form"); // NOI18N
        setLayout(new java.awt.BorderLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(administrador.AdministradorApp.class).getContext().getResourceMap(EstadoResultados.class);
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Resultados Obtenidos:", "", "", ""
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabla.setName("tabla"); // NOI18N
        jScrollPane1.setViewportView(tabla);

        jPanel2.setName("jPanel2"); // NOI18N

        lbl_nombre.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_nombre.setText(resourceMap.getString("lbl_nombre.text")); // NOI18N
        lbl_nombre.setName("lbl_nombre"); // NOI18N

        lbl_ruc.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_ruc.setText(resourceMap.getString("lbl_ruc.text")); // NOI18N
        lbl_ruc.setName("lbl_ruc"); // NOI18N

        lbl_titulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_titulo.setText(resourceMap.getString("lbl_titulo.text")); // NOI18N
        lbl_titulo.setName("lbl_titulo"); // NOI18N

        lbl_fecha.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbl_fecha.setText(resourceMap.getString("lbl_fecha.text")); // NOI18N
        lbl_fecha.setName("lbl_fecha"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbl_fecha, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                    .addComponent(lbl_titulo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbl_nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
                    .addComponent(lbl_ruc, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_nombre)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_ruc)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_titulo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_fecha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(15, 15, 15))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(203, 203, 203)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(65, 65, 65)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 486, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(156, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(171, Short.MAX_VALUE))
        );

        add(jPanel1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents
    public void configuroAnchoCol(){
    tabla.getColumn(tabla.getColumnName(0)).setMinWidth(300);
    tabla.getColumn(tabla.getColumnName(0)).setMaxWidth(300);
    tabla.getColumn(tabla.getColumnName(0)).setMaxWidth(300);
    
    
    //Pongo Colores:
    //Creo el Render
    RenderResultados miRender = new RenderResultados();
    //Aplico a la Tabla Deudores:
    tabla.setDefaultRenderer(Object.class, miRender);
    tabla.updateUI();
    
    }
    
    
    public void cargoDatos() {
//Cargo los Datos de la Cabecera del Balance de Comprobacion:
        ResultSet resp = conexion.consultarBase("SELECT * FROM parametros p");
        try {
            resp.beforeFirst();
            resp.next();
            //Nombre de la Empresa:
            lbl_nombre.setText(resp.getString(2));

            //Ruc de la Empresa:
            lbl_ruc.setText("RUC: "+resp.getString(3));
            
            //Fecha
            Date now = new Date();
            String fecha=lbl_fecha.getText()+DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(now);
            String[] fe=fecha.split(" ");
            
            fecha="";
            for(int i=0;i<6;i++){
            fecha=fecha+fe[i]+" ";
            }
            lbl_fecha.setText(fecha);
            
            
        } catch (SQLException ex) {
            
        }

        llenoCuentas();
    }

    public void llenoCuentas() {
        //Saco Ventas:
        int posicion=buscarCuenta(vMayor,"Ventas");
        Vector datos=(Vector) vMayor.elementAt(posicion);
        double saldo=Double.valueOf(datos.elementAt(2).toString());
        double ventasValor=saldo*-1;
        System.out.println("Ventas es ="+ventasValor);
        tabla.setValueAt("Ventas Brutas",0,0);
        tabla.setValueAt(nf.format(ventasValor),0,1);
        
        //Saco Desct Ventas:
        posicion=buscarCuenta(vMayor,"Descuento en Ventas");
        datos=(Vector) vMayor.elementAt(posicion);
        saldo=Double.valueOf(datos.elementAt(2).toString());
        double desctVentasValor=saldo;
        System.out.println("Descuento en Ventas es ="+desctVentasValor);
        tabla.setValueAt("Descuento en Ventas",1,0);
        tabla.setValueAt("("+nf.format(desctVentasValor)+")",1,1);
        
        //Saco Desct Ventas:
        posicion=buscarCuenta(vMayor,"Devolucion en Ventas");
        datos=(Vector) vMayor.elementAt(posicion);
        saldo=Double.valueOf(datos.elementAt(2).toString());
        double devVentasValor=saldo;
        System.out.println("Devolucion en Ventas es ="+devVentasValor);
        tabla.setValueAt("Devolucion en Ventas",2,0);
        tabla.setValueAt("("+nf.format(devVentasValor)+")",2,1);
        
        
        
        
        tabla.setValueAt("",3,1);
        //Saco Ventas Netas:
        double VentasNetas=ventasValor-desctVentasValor-devVentasValor;
        System.out.println("Ventas Netas="+VentasNetas);
        tabla.setValueAt("Ventas Netas",3,0);
        tabla.setValueAt(nf.format(VentasNetas),3,2);
        
        //Saco Compras:
//        posicion=buscarCuenta(vMayor,"Compras");
//        panelCuenta compras=(panelCuenta) vMayor.elementAt(posicion);
//        double comprasValor=compras.sacaSaldo();
//        System.out.println("Compras es ="+comprasValor);
        //Saco Desct Compras:
//        double comprasValor=0;
//        
//        posicion=buscarCuenta(vMayor,"Descuento en Compras");
//        panelCuenta desctCompras=(panelCuenta) vMayor.elementAt(posicion);
//        double desctComprasValor=desctCompras.sacaSaldo();
//        System.out.println("Descuento en Compras es ="+desctComprasValor);
//        //Saco Desct Compras:
//        posicion=buscarCuenta(vMayor,"Devolucion en Compras");
//        panelCuenta devCompras=(panelCuenta) vMayor.elementAt(posicion);
//        double devComprasValor=devCompras.sacaSaldo();
//        System.out.println("Devolucion en Compras es ="+devComprasValor);
//        //Saco Compras Netas:
//        double ComprasNetas=comprasValor-desctComprasValor-devComprasValor;
//        System.out.println("Compras Netas="+ComprasNetas);

        
           //Saco Costo de Ventas:
        posicion=buscarCuenta(vMayor,"Costo de Ventas");
        datos=(Vector) vMayor.elementAt(posicion);
        saldo=Double.valueOf(datos.elementAt(2).toString());
        double costoVentasValor=saldo;
        System.out.println("Costo de Ventas es ="+costoVentasValor);
        tabla.setValueAt("Costo de Ventas",4,0);
        tabla.setValueAt("("+nf.format(costoVentasValor)+")",4,2);
        
        
        tabla.setValueAt("",5,1);
        tabla.setValueAt("",5,2);
        
        //Saco Utilidad Bruta en Ventas:
        double UtilidadVentas=VentasNetas-costoVentasValor;
        System.out.println("Ventas Brutas es ="+UtilidadVentas);
        tabla.setValueAt("Utilidad en Ventas",5,0);
        tabla.setValueAt(nf.format(UtilidadVentas),5,3);
        
        //Saco Gastos:
            //Gastos Operacionales:
            //Sueldos y Salarios:
            posicion=buscarCuenta(vMayor,"Sueldos y Salarios");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double sueldosSalariosValor=saldo;
            System.out.println("Sueldos Salario es ="+sueldosSalariosValor);
            tabla.setValueAt("Sueldos y Salarios",6,0);
            tabla.setValueAt(nf.format(sueldosSalariosValor),6,1);
        
            //Comisiones a Comisiones a Vendedores:
            posicion=buscarCuenta(vMayor,"Comisiones a Vendedores");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double comisionVendedoresValor=saldo;
            System.out.println("Comisiones Vendedores es ="+comisionVendedoresValor);
            tabla.setValueAt("Comisiones a Vendedores",7,0);
            tabla.setValueAt(nf.format(comisionVendedoresValor),7,1);
            
             //Saco Horas Extras
            posicion=buscarCuenta(vMayor,"Horas Extras");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double horasExtrasValor=saldo;
            System.out.println("Horas Extras es ="+horasExtrasValor);
            tabla.setValueAt("Horas Extras",8,0);
            tabla.setValueAt(nf.format(horasExtrasValor),8,1);
            
            //Saco Arriendos Pagados:
            posicion=buscarCuenta(vMayor,"Arriendos Pagados");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double arriendosPagadosValor=saldo;
            System.out.println("Arriendos Pagados es ="+arriendosPagadosValor);
            tabla.setValueAt("Arriendos Pagados",9,0);
            tabla.setValueAt(nf.format(arriendosPagadosValor),9,1);
        
            //Publicidad y Propaganda:
            posicion=buscarCuenta(vMayor,"Publicidad y Propaganda");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
        
            double publicidadValor=saldo;
            System.out.println("Publicidad y Propaganda es ="+publicidadValor);
            tabla.setValueAt("Publicidad y Propaganda",10,0);
            tabla.setValueAt(nf.format(publicidadValor),10,1);
            
            //Servicios Basicos:
            posicion=buscarCuenta(vMayor,"Servicios Basicos");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double serviciosBasicosValor=saldo;
            System.out.println("Servicios Basicos es ="+serviciosBasicosValor);
            tabla.setValueAt("Servicios Basicos",11,0);
            tabla.setValueAt(nf.format(serviciosBasicosValor),11,1);
            
            //Gastos Varios:
            posicion=buscarCuenta(vMayor,"Gastos Varios");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double gastosVariosValor=saldo;
            System.out.println("Gastos Varios es ="+gastosVariosValor);
            tabla.setValueAt("Gastos Varios",12,0);
            tabla.setValueAt(nf.format(gastosVariosValor),12,1);
            
            //Intereces Pagados:
            posicion=buscarCuenta(vMayor,"Intereces Pagados");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double interesesPagadosValor=saldo;
            System.out.println("Intereces Pagados es ="+interesesPagadosValor);
            tabla.setValueAt("Intereces Pagados",13,0);
            tabla.setValueAt(nf.format(interesesPagadosValor),13,1);
            
            
            //Perdidas Ocacionales:
            posicion=buscarCuenta(vMayor,"Perdidas Ocasionales");
            datos=(Vector) vMayor.elementAt(posicion);
            saldo=Double.valueOf(datos.elementAt(2).toString());
            double perdidasOcacionalesValor=saldo;
            System.out.println("Perdidas Ocacionales es ="+perdidasOcacionalesValor);
            tabla.setValueAt("Perdidas Ocasionales",14,0);
            tabla.setValueAt(nf.format(perdidasOcacionalesValor),14,1);
            
            
            tabla.setValueAt("",15,1);
            tabla.setValueAt("",15,2);
            
            //Gastos Realizados:
            double gastos=sueldosSalariosValor+comisionVendedoresValor+horasExtrasValor+arriendosPagadosValor+publicidadValor+serviciosBasicosValor+gastosVariosValor+interesesPagadosValor+perdidasOcacionalesValor;
            tabla.setValueAt("Total Gastos",15,0);
            tabla.setValueAt("("+gastos+")",15,3);
            
            tabla.setValueAt("",16,1);
            tabla.setValueAt("",16,2);
            
    //Saco Utilidad Neta:
      double UtilidadNeta=UtilidadVentas-gastos;
      System.out.println("La utilidad del Ejercicio es:"+UtilidadNeta);
      tabla.setValueAt("Utilidad del Ejercicio",16,0);
      tabla.setValueAt(nf.format(UtilidadNeta),16,3);
        
    }
    
    public int buscarCuenta(Vector vectCuentas,String valor){
    int encontro=-1;    
    int tamano = vectCuentas.size();
    Vector datos=new Vector();
        for (int i = 0; i < tamano; i++) {
            datos=(Vector) vMayor.elementAt(i);
            String nombre=datos.elementAt(1).toString();
            if(nombre.equals(valor)){
            encontro=i;
            break;
            }
            
        }
        for (int i = 0; i < tamano; i++) {
            datos=(Vector) vMayor.elementAt(i);
            String codigo=datos.elementAt(0).toString();
            if(codigo.equals(valor)){
            encontro=i;
            break;
            }

        }
    
    return encontro;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbl_fecha;
    private javax.swing.JLabel lbl_nombre;
    private javax.swing.JLabel lbl_ruc;
    private javax.swing.JLabel lbl_titulo;
    private javax.swing.JTable tabla;
    // End of variables declaration//GEN-END:variables

}
